package com.mikufufu.blog.security.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public enum UserStatus {

    NORMAL(0, "正常"),
    DISABLED(1, "禁用"),
    LOCKED(2, "锁定"),
    ;

    private final Integer code;

    private final String name;

    /**
     * 根据code获取枚举
     *
     * @param code code
     * @return 枚举
     */
    public static String getName(int code) {
        for (UserStatus value : UserStatus.values()) {
            if (value.code == code) {
                return value.name;
            }
        }
        return null;
    }
}
